package com.mall.api.product;

import com.mall.api.product.dto.ProductDTO;
import com.mall.api.product.fallback.ProductFeignFallback;
import com.mall.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name = "mall-product", path = "/product", fallback = ProductFeignFallback.class)
public interface ProductFeignClient {

    @GetMapping("/{id}")
    Result<ProductDTO> getProductById(@PathVariable("id") Long id);

    @PostMapping("/create")
    Result<Void> createProduct(@RequestBody ProductDTO productDTO);

    @PutMapping("/update")
    Result<Void> updateProduct(@RequestBody ProductDTO productDTO);

    @DeleteMapping("/{id}")
    Result<Void> deleteProduct(@PathVariable("id") Long id);

    @PutMapping("/stock/{id}/{stock}")
    Result<Void> updateStock(@PathVariable("id") Long id, @PathVariable("stock") Integer stock);

    @GetMapping("/stock/{id}")
    Result<Integer> getStock(@PathVariable("id") Long id);
} 